﻿using System.Collections;
using PBMessage;
namespace GameUnit
{
    public class BehaviorAttribute : Behavior
    {
        public enum AttrType
        {
            INT,
            FLOAT,
            STRING
        }
        AttrType AttributeType;
        public object AttributeValue;
        public override void Init(Hashtable configTable,Unit srcUnit,long uuid)
        {
            base.Init(configTable, srcUnit, uuid);
            string strAttrType = (string)configTable[":attr-type"];
            switch (strAttrType)
            {
                case ":int":
                    this.AttributeType = AttrType.INT;
                    break;
                case ":float":
                    this.AttributeType = AttrType.FLOAT;
                    break;
                case ":string":
                    this.AttributeType = AttrType.STRING;
                    break;
            }
            this.AttributeValue = configTable[":attr-value"];
        }
        public override void OnServerBehaviorSync(SC_BehaviorOperation syncPacket)
        {
            for (int i = 0; i < syncPacket.FiledNames.Count; i++)
            {
                string filedName = syncPacket.FiledNames[i];
                switch (filedName)
                {
                    case "AttributeValue":
                        this.AttributeValue = syncPacket.FiledNameIntValues[i];
                    break;
                }
            }
        }
    }
}
